import { Tag } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import Copy from "@/components/business/copy"
import { orderStatusMap } from "@/utils/const"
import { getRebateCycle, handleNumberColor, handleTotalNumber, timeTurner } from "@/utils/util"

const incomeCheckRecord = (
	newFormat: (arg: string) => string,
	getFromDic: (arg: string, strictlyLabel?: boolean) => any,
	symbolCurrency: string
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	incomeCheckRecord_orderNo: {
		key: "incomeCheckRecord_orderNo",
		align: "center",
		dataIndex: "orderNo",
		title: newFormat("funds.order_no"),
		width: 280,
		render: (orderNo: string) => <Copy text={orderNo} />
	},
	incomeCheckRecord_settlementCycle: {
		key: "incomeCheckRecord_settlementCycle",
		align: "center",
		dataIndex: "startTime",
		title: newFormat("funds.fund_audit.actual_revenue"),
		width: 200,
		render: (startTime: string, record: any) => getRebateCycle(startTime, record.endTime)
	},
	incomeCheckRecord_proxyName: {
		key: "userName",
		align: "center",
		dataIndex: "proxyName",
		title: newFormat("funds.proxy_name"),
		render: (text: string) => <Copy text={text} />,
		width: 200
	},
	incomeCheckRecord_businessModel: {
		key: "incomeCheckRecord_businessModel",
		align: "center",
		dataIndex: "businessModel",
		title: newFormat("funds.fund_audit.business_model"),
		width: 150,
		render: getFromDic("businessModel", false)
	},
	incomeCheckRecord_proxyLevel: {
		key: "incomeCheckRecord_proxyLevel",
		align: "center",
		dataIndex: "proxyLevel",
		title: newFormat("funds.proxy_member_funds_record.proxy_level_name"),
		width: 150
	},
	incomeCheckRecord_merchantName: {
		key: "incomeCheckRecord_merchantName",
		align: "center",
		dataIndex: "merchantName",
		title: newFormat("funds.proxy_member_funds_record.parent_proxy_account"),
		width: 150,
		render: (_: string, record: any) =>
			record.parentProxyName === "-" ? record.parentProxyName : <Copy text={record.parentProxyName} />
	},
	incomeCheckRecord_topProxyName: {
		key: "incomeCheckRecord_topProxyName",
		align: "center",
		dataIndex: "topProxyName",
		title: newFormat("funds.proxy_member_funds_record.top_proxy_name"),
		width: 150,
		render: (topProxyName: string) => <Copy text={topProxyName} />
	},
	incomeCheckRecord_currentIncomeAmount: {
		key: "incomeCheckRecord_currentIncomeAmount",
		align: "center",
		dataIndex: "currentIncomeAmount",
		title: newFormat("funds.fund_audit.current_period_revenue"),
		width: 150,
		render: (currentIncomeAmount: string) => handleTotalNumber(symbolCurrency, "USDT", currentIncomeAmount)
	},
	incomeCheckRecord_adjustIncomeAmount: {
		key: "incomeCheckRecord_adjustIncomeAmount",
		align: "center",
		dataIndex: "adjustIncomeAmount",
		title: newFormat("funds.fund_audit.revenue_adjustment"),
		width: 150,
		render: (adjustIncomeAmount: number) => (
			<div style={{ color: handleNumberColor(adjustIncomeAmount) }}>
				{handleTotalNumber(symbolCurrency, "USDT", adjustIncomeAmount)}
			</div>
		)
	},
	incomeCheckRecord_realIncomeAmount: {
		key: "incomeCheckRecord_realIncomeAmount",
		align: "center",
		dataIndex: "realIncomeAmount",
		title: newFormat("funds.fund_audit.adjusted_revenue"),
		width: 150,
		render: (realIncomeAmount: number) => handleTotalNumber(symbolCurrency, "USDT", realIncomeAmount)
	},
	incomeCheckRecord_orderStatus: {
		key: "incomeCheckRecord_orderStatus",
		align: "center",
		dataIndex: "auditStatus",
		title: newFormat("funds.fund_audit.order_status"),
		width: 150,
		render: (auditStatus: number) => (
			<Tag color={auditStatus === 4 ? "#87d068" : "red"}>
				{newFormat(orderStatusMap[auditStatus as keyof typeof orderStatusMap]) || "-"}
			</Tag>
		)
	},
	incomeCheckRecord_auditTime: {
		key: "incomeCheckRecord_auditTime",
		align: "center",
		dataIndex: "audit1Time",
		title: newFormat("funds.fund_audit.audit_time"),
		width: 250,
		render: (audit1Time: number, record: any) => (
			<>
				<div>{`${newFormat("funds.fund_audit.audit_text_1") + ": " + audit1Time || "-"}`}</div>
				{record.audit1Result === 1 && (
					<div>{`${newFormat("funds.fund_audit.audit_text_2") + ": " + record.audit2Time || "-"}`}</div>
				)}
			</>
		)
	},
	incomeCheckRecord_auditCost: {
		key: "incomeCheckRecord_auditCost",
		align: "center",
		dataIndex: "audit1Cost",
		title: newFormat("funds.fund_audit.audit_time"),
		width: 220,
		render: (audit1Cost: number, record: any) => (
			<>
				<div>{`${newFormat("funds.fund_audit.audit_text_1") + ": " + timeTurner(audit1Cost) || "-"}`}</div>
				{record.audit1Result === 1 && (
					<div>{`${newFormat("funds.fund_audit.audit_text_2") + ": " + timeTurner(record.audit2Cost) || "-"}`}</div>
				)}
			</>
		)
	},
	incomeCheckRecord_lockAccount: {
		key: "incomeCheckRecord_lockAccount",
		align: "center",
		dataIndex: "audit1Operator",
		title: newFormat("funds.fund_audit.lock_account"),
		width: 220,
		render: (audit1Operator: number, record: any) => (
			<>
				<div>{`${newFormat("funds.fund_audit.audit_text_1") + ": " + audit1Operator || "-"}`}</div>
				{record.audit1Result === 1 && (
					<div>{`${newFormat("funds.fund_audit.audit_text_2") + ": " + record.audit2Operator || "-"}`}</div>
				)}
			</>
		)
	}
})
export default incomeCheckRecord
